import cookies from "vue-cookies";
export default {
  state: {
    userInfo: "",
    uniacid: "0"
  },
  mutations: {
    // 登录成功 vuex 和 cookies 中保存数据
    setUser(state, val) {
      state.userInfo = val;
    },
    setUniacid(state, val) {
      state.uniacid = val;
    },
    setUserInfo(state, val) {
      state.userInfo = val.user;
      state.uniacid = val.uniacid;
    },
    // 退出登录的时候清除
    clearToken(state) {
      state.userInfo = "";
      state.uniacid = 0;
      cookies.remove("userInfo");
      cookies.remove("uniacid");
    },
    // 刷新的时候保存数据
    getUserInfo(state) {
      state.userInfo = cookies.get("userInfo");
      state.uniacid = cookies.get("uniacid");
    }
  },
  actions: {}
};
